<template>
	<div class="adm6">
		<div class="box1">
			<h3>管理员添加</h3>
			<el-input type="text" placeholder="请输入昵称" v-model="adm6.nickname" maxlength="11" show-word-limit>
				<template slot="prepend" style="width: 300px;">用户昵称</template>
			</el-input>
			<el-input type="text" placeholder="请输入账号" v-model="adm6.account" maxlength="11" show-word-limit>
				<template slot="prepend" style="width: 300px;">用户账号</template>
			</el-input>
			<el-input type="text" placeholder="请输入密码" v-model="adm6.password" oninput="value=value.replace(/[^\d]/g,'')" maxlength="6" show-word-limit>
				<template slot="prepend" style="width: 300px;">用户密码</template>
			</el-input>
			<el-input type="text" placeholder="请输入手机号" v-model="adm6.phone" oninput="value=value.replace(/[^\d]/g,'')" maxlength="11" show-word-limit>
				<template slot="prepend">手机号码</template>
			</el-input>
				<el-upload class="avatar-uploader" :multipe="false" :show-file-list="true" :auto-upload="false"
					:file-list="fileList" :on-change="handleChange"
					action="uploadAction" list-type="picture" accept="image/jpg,image/jpeg">
					<h2>点击这里选择图片</h2>
				</el-upload>
			<div style="margin-top: 15px;">
				<el-button type="primary" @click="add()">添加</el-button>
			</div>
		</div>
	</div>
</template>

<script>
	export default {
		name: 'adm6',
		props: [],
		data() {
			return {
				adm6:{},
				fileList:[],
			}
		},
		methods: {
			add() {
				let that = this
				let fd = new FormData();
				let fs = this.fileList;
				if(fs.length > 0 && fs[0].raw != null) {
					//文件上传
					fd.append("pic", fs[0].raw)
				}
				fd.append("nickname", this.adm6.nickname)
				fd.append("account", this.adm6.account)
				fd.append("password", this.adm6.password)
				fd.append("phone", this.adm6.phone)
				this.axios.post("/api/adm/user/addAdm",
					fd,
					{header:{'Content-Type':'application/json'}}
				)
				.then(function(resp){
					console.log(resp.data)
				})
			},
			handleChange(file,fileList){
				this.fileList = fileList
				console.log(this.fileList)
			}
		},
	}
</script>

<style scoped>
.box1{
	width: 500px;
	height: 750px;
	margin-left: 400px;
	line-height: 50px;
}
.box1 h3{
	font-size: 1.5rem;
	font-weight: bold;
}

</style> 
